<%@page import="com.glowdayz.glowmee.dao.RegisterDAO"%>
<%@ page language="java" contentType="text/xml; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@page import="com.glowdayz.common.DBHandler"%>
<%@page import="com.glowdayz.common.ApiHandler"%>
<%@page import="com.glowdayz.common.ApiHandler.XmlData"%>
<%@page import="java.util.ArrayList"%>
<%
	DBHandler.getInstance().connect();

	ApiHandler web = new ApiHandler(request, out, "JSPglowmee");
	
	int idRegister = web.getInt("idRegister");
	int idPouch = web.getInt("idPouch");
	
	int commentCount = DBHandler.getInstance().getCount("wishuserpouchmapping", "*", "idRegister=" + idRegister + " AND idPouch=" + idPouch);
	
	if (commentCount > 0) {
		DBHandler.getInstance().disconnect();
		web.result(null, "이미 해당 픽을 추천하셨습니다.");
		return;
	}
	
	int insert = 0;
	
	insert = RegisterDAO.getInstance().wishListPouch(idRegister, idPouch);
	
	if (insert < 1) {
		DBHandler.getInstance().disconnect();
		web.result(null, "추가에 실패하였습니다.");
		return;
	}
	
	DBHandler.getInstance().disconnect();
	
	ArrayList<XmlData> list = new ArrayList<XmlData>();
	list.add(new XmlData("seq", insert));
	web.result("SUCCESS", "(추천완료) 나의 프로필에서 확인하세요.", list);
%>